<template lang="pug">
  keep-alive
    kalix-table(bizKey="scorequery" title="成绩列表"
    v-bind:targetURL="targetURL" v-bind:tableFields="tableFields" bizSearch="ScoreSearch"
    v-bind:btnList="btnList" v-bind:customTableTool="customTableTool"
    v-bind:toolbarBtnList="toolbarBtnList" v-bind:customRender="customRender"
    ref="scoreTable")
</template>

<script>
  import {ScoreQueryURL} from '../config.toml'
  import {ScoreBtnList} from './config'

  export default {
    name: 'kalix-exam-scorequery',
    data() {
      return {
        targetURL: ScoreQueryURL,
        btnList: ScoreBtnList,
        tableFields: [
          {prop: 'name', label: '考试名称'},
          {prop: 'subject', label: '考试科目'},
          {prop: 'startTime', label: '考试时间'},
          {prop: 'totalScore', label: '考试成绩'}
        ],
        toolbarBtnList: [
          {id: 'add', isShow: false}
        ]
      }
    },
    methods: {
      customRender(_data) {
        _data.forEach(function (e) {
          e.totalScore = e.totalScore === null ? '批阅中' : e.totalScore
        })
      },
      customTableTool(row, btnId, _kalixTable) {
        console.log('row', row)
        switch (btnId) {
          case 'paperShowView':
            _kalixTable.whichBizDialog = 'scoreView'
            this.$nextTick(() => {
              _kalixTable.$refs.kalixDialog.open(row)
            })
            break
        }
      }
    }
  }
</script>

<style lang="stylus" rel="stylesheet/stylus">
  @import '../examing/exam-dialog.styl'
</style>
